#!/bin/bash
#


#设置参数
test="/root/test/"
test1="/root/test1/"
sum1=0
sum2=0
#判断文件是否丢失
for i in `find /root/test/ -name "test*"|awk -F'/root/test' '{print $2}'`; do
	t=false
	let sum1++
	for j in `find /root/test1/ -name "test*"|awk -F'/root/test1' '{print $2}'`; do
		if [ $i == $j ];then
			let sum2++
			t=true		
			continue
		fi		
	done

	if [ $t == false ];then
		echo "在$test1 目录下$i 文件丢失"
	fi

done
#判断文件内容是否缺失
for i in `find /root/test/ -name "test*"|awk -F'/root/test' '{print $2}'`; do
	t=false
	for j in `find /root/test1/ -name "test*"|awk -F'/root/test1' '{print $2}'`; do
		if [ $i == $j ];then
			diff ${test}${i} ${test1}${j} &> /dev/null 
			if [ $? != 0 -a $i != / ];then
				echo -e "$test1 目录下的 $i 文件内容有误: `diff ${test}${i} ${test1}${j}` \n"
			fi
			continue
		fi		
	done
done
